Do not consume statement terminator in unparenthesized option lists#2376
Open
LucaCappelletti94 wants to merge 1 commit into
Open
Do not consume statement terminator in unparenthesized option lists#2376LucaCappelletti94 wants to merge 1 commit into
LucaCappelletti94 wants to merge 1 commit into
Conversation
a2faf7b to
dabfe2b
Compare
CREATE USER option list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CREATE USER <name>andALTER USER <name> SET ...parse on their own, butCREATE USER user1; SELECT 1(and the twoALTER USER ... SETforms) fail withExpected: end of statement, found: SELECT. The trailing option list is read byparse_key_value_options, whose loop drives onnext_token()and breaks on a;that it has already consumed. With the terminator gone, the top-level statement loop sees the next statement's first token directly and errors out. The bug is dialect independent and affects every unparenthesized caller of the helper:CREATE USERand bothALTER USER ... SETbranches. Statements that never reach the helper (CREATE ROLE,DROP USER,ALTER USER ... RENAME) are unaffected, as are the parenthesized callers, which end on).This puts the semicolon back with
prev_token()before breaking, so the caller and the top-level loop still see the separator, mirroring how the existing end-keyword arm already does it. TheEOFarm needs no rewind. Fixing the single helper repairs all three statements at once. A regression test parses each of the three forms followed bySELECT 1and asserts two statements result.